<?php if (!defined('THINK_PATH')) exit();?><!doctype html>
<html class="no-js">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="description" content="">
    <meta name="keywords" content="">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
    <title><?php echo ($title); ?></title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="Cache-Control" content="no-siteapp"/>
    <meta name="mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="apple-mobile-web-app-title" content="Amaze UI"/>
    <meta name="msapplication-TileColor" content="#0e90d2">
    <link rel="stylesheet" href="/Public/assets/css/amazeui.min.css">
    <link rel="stylesheet" href="/Public/assets/css/app.css">

    <script src="/Public/assets/js/jquery.min.js"></script>
    <script src="/Public/assets/js/amazeui.js"></script>
    <script src="/Public/assets/js/handlebars.min.js"></script>
    <script src="/Public/assets/js/amazeui.widgets.helper.js"></script>

</head>
<body>
<div class="am-container">
    <header class="am-topbar">
        <div class="navbar-div">
            <input type="text" class="am-form-field am-input-sm search-text" placeholder="输入你要搜索的内容" id="o" onkeyup="autoComplete.start(event)">
            <button type="submit" class="am-btn am-btn-default am-btn-sm"><span class="am-icon-search"></span>搜索</button>
            <button class="am-topbar-btn am-topbar-toggle am-btn am-btn-sm am-btn-success"
                    data-am-collapse="{target: '#doc-topbar-collapse'}">排序</button>
        </div>
        <div class="auto_hidden" id="auto"><!--自动补全 DIV--></div>

        <div class="am-collapse am-topbar-collapse" id="doc-topbar-collapse">
            <ul class="am-nav am-nav-pills am-topbar-nav angel">
                <li><a href="#"><span class="am-icon-align-justify"></span>名称</a></li>
                <li><a href="#"><span class="am-icon-money"></span>金额</a></li>
                <li><a href="#"><span class="am-icon-filter"></span>阶段</a></li>
                <li class="am-active"><a href="#"><span class="am-icon-calendar"></span>时间</a></li>
                <li><a href="#"><span class="am-icon-ban"></span>停滞期</a></li>
            </ul>
        </div>
    </header>

    <div class="fx-list-hd">
        <div class="am-g am-g-headFs am-text-center">
            <div class="am-u-sm-3">数量：<span class="c-orange"><?php echo ($data3["count"]); ?></span></div>
            <div class="am-u-sm-5">金额：<span class="c-orange"><?php echo ($data3["amount"]); ?></span>万</div>
            <div class="am-u-sm-4">预计：<span class="c-orange"><?php echo ($data3["estimate"]); ?></span>万</div>
        </div>
    </div>
    <ul class="am-list am-list-static myProject-list">
        <?php if(is_array($data)): $i = 0; $__LIST__ = $data;if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$vo): $mod = ($i % 2 );++$i;?><li>
                <div class="vbox">
                    <div class="cbox" id="<?php echo ($vo["pid"]); ?>">
                        <div class="del-button">
                            <button id="project_<?php echo ($vo["pid"]); ?>" class="am-btn am-btn-danger" onclick="window.location.href='/index.php/Admin/Data/delete/id/<?php echo ($vo["pid"]); ?>'">
                                <span class="am-icon-trash am-icon-sm"></span>
                            </button>
                            <!-- /fms/delete/id/<?php echo ($vo["pid"]); ?> -->
                        </div>
                        <div class="am-g am-g-diy pdetail">
                            <div class="am-u-sm-8 am-text-truncate"><?php echo ($vo["name"]); ?></div>
                            <div class="am-u-sm-4 am-text-truncate"><?php echo ($vo["cdate"]); ?></div>
                            <div class="am-u-sm-4 am-text-truncate am-text-sm"><span class="c-orange"><?php echo ($vo["amount"]); ?></span>万</div>
                            <div class="am-u-sm-4 am-text-truncate am-text-sm"><span class="c-orange"><?php echo ($vo["sname"]); ?></span></div>
                            <div class="am-u-sm-4 am-text-truncate am-text-sm"><span class="c-gray">停滞<?php echo ($vo["days"]); ?>天</span></div>
                        </div>
                    </div>
                </div>
            </li><?php endforeach; endif; else: echo "" ;endif; ?>
    </ul>
</div>
<!-- /.am-container -->

<div class="am-g">
    <div class="am-u-sm-12 am-text-center">
        <a href="<?php echo U('addProject');?>"><span class="am-icon-plus am-icon-md c-gray"></span></a>
    </div>
</div>

<div class="am-modal am-modal-prompt" tabindex="-1" id="my-prompt">
    <div class="am-modal-dialog">
        <div class="am-modal-hd">修改我的项目</div>
        <div class="am-modal-bd p-id" style="display: none;">
            <input type="text" class="am-modal-prompt-input">
        </div>
        <div class="am-modal-bd new-name">
            新名称：
            <input type="text" class="am-modal-prompt-input" oninput="OnInput(event)">
        </div>
        <div class="am-modal-bd new-amount">
            新金额：
            <input type="text" class="am-modal-prompt-input" oninput="OnInput(event)">
        </div>
        <div class="am-modal-bd new-stage">
            新阶段：
<!--            <input type="text" class="am-modal-prompt-input" oninput="OnInput(event)">-->
            <select class="am-form-field am-modal-prompt-input" name="stage" id="stage">
                <?php if(is_array($data2)): $i = 0; $__LIST__ = $data2;if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$vo): $mod = ($i % 2 );++$i;?><option value=<?php echo ($vo); ?>><?php echo ($vo); ?></option><?php endforeach; endif; else: echo "" ;endif; ?>
                <span class="am-form-caret"></span>
            </select>
        </div>
        <div class="am-modal-bd old-stage" style="display: none;">
            旧阶段：
            <input type="text" class="am-modal-prompt-input" oninput="OnInput(event)">
        </div>
        <div class="am-modal-bd new-cdate">
            新合同日期：
<!--            <input type="text" class="am-modal-prompt-input" oninput="OnInput(event)">-->
            <input  id="endTime" class="am-form-field kbtn am-modal-prompt-input" name="addtime" placeholder="新合同日期" />
            <div id="datePlugin"></div>
        </div>
        <div class="am-modal-footer">
            <button class="am-modal-btn">取消</button>
            <button class="am-btn" data-am-modal-confirm>提交</button>
        </div>
    </div>
</div>

<script type="text/javascript">
    var allTitle = {};
    $('.pdetail').on('click', function() {
        var pid = $(this).parent().attr('id');
        var oldName = $(this).parent().find('.am-u-sm-8').text();
        var oldCdate = $(this).parent().find('.am-u-sm-8').next().text();
        var oldAmount = $(this).parent().find('.am-u-sm-8').next().next().text();
        var oldStage = $(this).parent().find('.am-u-sm-8').next().next().next().text();
        allTitle = checkTitle(pid);  //获取所有项目名
        $('.p-id').children('input').val(pid);
        $('.new-name').children('input').val(oldName);
        $('.new-amount').children('input').val(oldAmount);
        $('.new-stage').children('select').val(oldStage);
        $('.old-stage').children('input').val(oldStage);
        $('.new-cdate').children('input').val(oldCdate);
        $('.am-modal-footer .am-btn').removeAttr('disabled');
        $('#my-prompt').find('.am-icon-sm').remove();
        $('#my-prompt').modal({
            relatedTarget: this,
            onConfirm: function(e) {
                alert('你输入的是：' + e.data || '')

                $.ajax({
                    type:"post",
                    url:"<?php echo U('Data/updatePro');?>", ///fms/updatePro
                    data:{"data": e.data},
                    dataType:"json",
//                    error:function(result),
                    success:function(result){
                        alert(result.msg);
                        if(result.status == 'done'){                   //************修改列表中对应的项目值***********
                            $("#"+result.data['pid']).find('.am-u-sm-8').text(result.data['name']);
                            $("#"+result.data['pid']).find('.am-u-sm-8').next().text(result.data['cdate']);
                            $("#"+result.data['pid']).find('.am-u-sm-8').next().next().children().text(result.data['amount']);
                            $("#"+result.data['pid']).find('.am-u-sm-8').next().next().next().children().text(result.data['stage']);
                            if(typeof (result.data['updtime']) != 'undefined'){
                                $("#"+result.data['pid']).find('.am-u-sm-4:last-child').children().text("停滞0天");
                            }
                            $('.am-modal-footer .am-modal-btn').trigger("click");
                        }
                    }
                });
            },
            onCancel: function(e) {
//                alert('已取消!');
            }
        });
    });

    function checkTitle(pid){
        var res = '';
        $.ajax({
            type:"post",
            url:"<?php echo U('Data/checkTitle');?>", ///fms/checkTitle
            data:{"pid": pid},
            dataType:"json",
            async:false,
            success:function(result){
                if(result.status == 'done'){
                    res = result.data;
                }
            }
        });
        return res;
    }

    function OnInput(event) {
        var pass = "<span class='am-icon-check-circle-o am-icon-sm c-green pass'></span>";
        var fail = "<span class='am-icon-times-circle-o am-icon-sm c-red fail'></span>";
        var repeat = "<span class='am-icon-times-circle-o am-icon-sm c-red repeat'>重复</span>";
        var input = event.target.value;
        if(input == ''){
            $(event.target).prev('.am-icon-sm').remove();
            $(event.target).parent().prepend(fail);
            $('.am-modal-footer .am-btn').attr('disabled','disabled');
        }
        else if(input != ''){
            $(event.target).prev('.am-icon-sm').remove();
            if($(event.target).parent().hasClass('new-name')){
                //************根据已有项目名称,验证名称是否重复***********
                if($.inArray(input, allTitle) != '-1'){
                    $(event.target).parent().prepend(repeat);
                }
                else{
                    $(event.target).parent().prepend(pass);
                    $('.am-modal-footer .am-btn').removeAttr('disabled');
                }
            }
            else{
                $(event.target).parent().prepend(pass);
                $('.am-modal-footer .am-btn').removeAttr('disabled');
            }
        }
    }

</script>

<script src="/Public/assets/js/date.js"></script>
<script src="/Public/assets/js/iscroll.js"></script>
<script type="text/javascript">
    $(function(){
        $('#endTime').date();
        $('#beginTime').date({theme:"datetime"});
    });
</script>
<!--<script src="/assets/js/search-tips.js"></script>-->

<div data-am-widget="navbar" class="am-navbar am-cf am-navbar-default" id="">
    <ul class="am-navbar-nav am-cf am-avg-sm-4 green">
        <li>
            <a href="<?php echo U('index');?>" class="">
                <span class="am-icon-building-o"></span>
                <span class="am-navbar-label">我的项目</span>
            </a>
        </li>
        <li>
            <a href="<?php echo U('myReport');?>" class="">
                <span class="am-icon-bar-chart-o"></span>
                <span class="am-navbar-label">报表</span>
            </a>
        </li>
        <li>
            <a href="<?php echo U('history');?>" class="">
                <span class="am-icon-history"></span>
                <span class="am-navbar-label">历史</span>
            </a>
        </li>
        <li>
            <a href="<?php echo U('teamReport');?>" class="">
                <span class="am-icon-users"></span>
                <span class="am-navbar-label">团队</span>
            </a>
        </li>
        <li>
            <a href="<?php echo U('estimate');?>" class="">
                <span class="am-icon-cloud"></span>
                <span class="am-navbar-label">预计</span>
            </a>
        </li>
        <li>
            <a href="<?php echo U('busi');?>" class="">
                <span class="am-icon-cny"></span>
                <span class="am-navbar-label">商机</span>
            </a>
        </li>
        <li>
            <a href="<?php echo U('stageConf');?>" class="">
                <span class="am-icon-cog"></span>
                <span class="am-navbar-label">配置</span>
            </a>
        </li>
        <li>
            <a href="<?php echo U('aboutUs');?>" class="">
                <span class="am-icon-tag"></span>
                <span class="am-navbar-label">关于</span>
            </a>
        </li>
        <li data-am-navbar-qrcode>
            <a>
                <span class="am-icon-qrcode"></span>
                <span class="am-navbar-label">二维码</span>
            </a>
        </li>
    </ul>
</div>
<!-- /.am-navbar -->

</body>
</html>